{
LANG : PASCAL
PROB : ride
}

program RIDE;
const
  fi = 'ride.in';
  fo = 'ride.out';
var
  star, group : string;
  i, s, g : longint;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  readln(star);
  readln(group);
  s := 1;
  for i := 1 to length(star) do s := s * (ord(star[i]) - 64);
  g := 1;
  for i := 1 to length(group) do g := g * (ord(group[i]) - 64);
  if (s mod 47) = (g mod 47) then writeln('GO')
  else writeln('STAY');
  close(output);
  close(input);
end.